<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">
        <div class=" rc-pannel ">
            <div class=" rc-pannel-header">
                <div class="rc-flex layui-form toolbar rc-flex-justify-between">
                    <div class=" rc-flex rc-flex-vertical-center ">

                    </div>
                    <div>


                        <a href="/app/cms/admin/AiPublish/addKeyword" class="layui-btn layui-btn-primary layui-btn-sm"><i class="iconfont">&#xe60e;</i> 添加发文关键词</a>

                    </div>
                </div>


            </div>


            <div class="rc-pannel-body layui-form rc-pagepadding">

                <blockquote class="layui-elem-quote">
                    自动发文需要配合《CMS(免费版)AI自动发文》事件使用，并在计划任务里调用该事件。
                </blockquote>

                <table class="layui-table">
                    <colgroup>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col style="width: 200px;">
                    </colgroup>
                    <thead>
                        <tr>
                            <th>关键词</th>
                            <th>发布栏目</th>
                            <th>最大发文数量</th>
                            <th>已发文数量</th>
                            <th>AI模型</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>

                        <?php
                        foreach ($keywords as $keyword) {
                        ?>
                            <tr>
                                <td><?php echo $keyword->keyword ?></td>
                                <td>
                                    <?php
                                    foreach ($keyword->cateancestors as $cate) {
                                        echo $cate['title'] . ' ';
                                    }
                                    ?>

                                </td>
                                <td><?php echo $keyword->maxcount ?></td>
                                <td><?php echo $keyword->publiscount ?></td>
                                <td><?php echo $keyword->aimodeltitle ?></td>
                                <td>
                                    <div class="rc-opbar">

                                        <a class="info" href="/app/cms/admin/AiPublish/editKeyword?id=<?php echo $keyword->id ?>"><i class="iconfont">&#xe606;</i> 编辑</a>

                                        <a class="error delete" keywordid="<?php echo $keyword->id ?>"><i class="iconfont">&#xe607;</i> 删除 </a>
                                    </div>


                                </td>
                            </tr>
                        <?php
                        }
                        ?>




                    </tbody>
                </table>


            </div>

            <div class="rc-pannel-footer " style="text-align:right">
                <div style="padding: 0 15px;">
                    <?php echo paginator($keywords->total(), 20) ?>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(function() {

        var layer = layui.layer;



        $('.delete').click(function() {
            var keywordid = $(this).attr('keywordid');
            layer.confirm('确定要删除么？', {
                btn: ['确定', '关闭'] //按钮
            }, function() {
                $.ajax({
                    url: '/app/cms/admin/AiPublish/delKeyword?keywordid=' + keywordid, //请求路径
                    type: "POST", //请求方式
                    success: function(data) {
                        if (data.code != 0) {
                            toastr_error(data.message);
                        } else {
                            window.location.reload();
                        }
                    },
                    error: function() {},
                    complete: function() {
                        layer.closeAll();
                    }
                });
            }, function() {


            });
        });

    });
</script>